package com.openx.amqp;

import java.util.HashMap;
import java.util.Map;

/**
 * 交换类型
 * @ClassName: XExchangeType
 * @author quanyou.chen
 * @date: 2017年10月31日 下午2:30:52
 * @version  v 1.0
 */
public enum XExchangeType {
    system("system"),direct("direct"),fanout("fanout"),header("headers"),topic("topic");
    
    private String value;
    
    
    XExchangeType(String value) {
        this.value = value;
    }
    
    @Override
    public String toString() {
        return this.value;
    }
    
    private static final Map<String, XExchangeType> stringToEnum = new HashMap<String, XExchangeType>();
    static {
        // Initialize map from constant name to enum constant
        for(XExchangeType type : values()) {
            stringToEnum.put(type.toString(), type);
        }
    }
    
    // Returns XExchangeType for string, or null if string is invalid
    public static XExchangeType fromString(String symbol) {
        return stringToEnum.get(symbol);
    }
}
